package com.itheima.health.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.mapper.CheckItemMapper;
import com.itheima.health.pojo.CheckItem;
import com.itheima.health.service.CheckItemService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressWarnings("ALL")
/**
 * @Description :
 * @author     :LD
 */
@Service
@Transactional
public class CheckItemServiceImpl extends ServiceImpl<CheckItemMapper, CheckItem> implements CheckItemService {
    @Override
    public Map findPageCondition(QueryPageBean queryPageBean) {
        QueryWrapper<CheckItem> queryWrapper = new QueryWrapper<>();
        //有效数据
        queryWrapper.eq("is_delete",0);
        String queryString = queryPageBean.getQueryString();//  条件
        queryWrapper.like("name",queryString==null?"":queryString);
        Page<CheckItem> page = page(new Page<CheckItem>(queryPageBean.getCurrentPage(), queryPageBean.getPageSize()),queryWrapper);
        List<CheckItem> items = page.getRecords();
        long total = page.getTotal();
        Map map = new HashMap();
        map.put("list",items);
        map.put("total",total);
        return map;
    }

    @Override
    public List<CheckItem> findAll() {
        QueryWrapper<CheckItem> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_delete",0);
        return list(queryWrapper);
    }
}
